#include "stdafx.h"
#include "actionpausehandler.h"

namespace {
const unsigned GLOBAL_PAUSE = 40;
const unsigned PAUSE_STAFF = GLOBAL_PAUSE;
//const unsigned TBA = TBA;
//const unsigned TBA = TBA;
//const unsigned TBA = TBA;
//const unsigned TBA = TBA;
//const unsigned TBA = TBA;
//const unsigned TBA = TBA;

unsigned getActionCooldown(ISelfControl::Action action)
{
    switch (action)
    {
        default:
            return 0;
        case ISelfControl::Action_Staff:
            return PAUSE_STAFF;
    }
}

}

ActionPauseHandler::ActionPauseHandler()
{
}

ActionPauseHandler::~ActionPauseHandler()
{
}

unsigned ActionPauseHandler::getActionPause(ISelfControl::Action action) const
{
    return _pauses[action];
}

void ActionPauseHandler::setFullPause(ISelfControl::Action action)
{
    unsigned cooldown = getActionCooldown(action);
    if (cooldown == 0)
        return;

    for (unsigned index = 0; index < ISelfControl::ActionsNum; ++index)
        if (_pauses[index] < GLOBAL_PAUSE)
            _pauses[index] = GLOBAL_PAUSE;
    _pauses[action] = cooldown;
}

void ActionPauseHandler::decrease()
{
    for (unsigned index = 0; index < ISelfControl::ActionsNum; ++index)
        if (_pauses[index] > 0)
            --_pauses[index];
}
